using System;
using UnityEngine;

namespace Voodoo.Sauce.Internal
{
	[Serializable]
	public class VoodooVersion : ScriptableObject
	{
		public const string NAME = "VoodooVersion";

		[ReadOnly]
		public uint Major;

		[ReadOnly]
		public uint Minor;

		[ReadOnly]
		public uint Hotfix;

		[ReadOnly]
		public string Label = "";

		[ReadOnly]
		public int BuildNumber = -1;

		public static VoodooVersion Load()
		{
			return Resources.Load<VoodooVersion>("VoodooVersion");
		}

		public new string ToString()
		{
			return string.Format("{0}.{1}.{2}{3}{4}", Major, Minor, Hotfix, (Label.Length == 0) ? "" : ("." + Label), (BuildNumber < 0) ? "" : $".{BuildNumber}");
		}

		public void BumpMajor(string label = "")
		{
			Major++;
			Minor = 0u;
			Hotfix = 0u;
			Label = label;
		}

		public void BumpMinor(string label = "")
		{
			Minor++;
			Hotfix = 0u;
			Label = label;
		}

		public void BumpHotfix(string label = "")
		{
			Hotfix++;
			Label = label;
		}

		public void BumpBuildNumber()
		{
			BuildNumber++;
		}

		public void ResetBuildNumber()
		{
			BuildNumber = 0;
		}

		public void DisableBuildNumber()
		{
			BuildNumber = -1;
		}

		public void UpdateLabel(string label = "")
		{
			Label = label;
		}

		public void UpdateVersion(uint major, uint minor, uint hotfix, int buildNumber, string label = "")
		{
			Major = major;
			Minor = minor;
			Hotfix = hotfix;
			Label = label;
			BuildNumber = buildNumber;
		}

		public void Save()
		{
		}
	}
}
